package 力扣算法练习.main1.newPart1;

import java.util.Stack;

public class day7 {
    //https://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2?tpId=37&tqId=21309&ru=/exam/oj
    public void findContinuity(int number){
        //先将十进制转为二进制
        Stack<Integer> temp=new Stack<>();
        int t=0,result=0;;
        while(number!=0){
            t=number%2;
            temp.add(t);
            number/=2;
        }
        t=0;
        //判断有多少个连续的1
        while(!temp.isEmpty()){
            if(temp.pop()==1){
                t++;
            }else{
                t=0;
            }
            if(t>result){
                result=t;
            }
        }
        System.out.println(result);
    }

    //https://www.nowcoder.com/questionTerminal/70e00e490b454006976c1fdf47f155d9
    public int getLCA(int a, int b) {
        // write code here
        while(a!=b){
            if(a>b){
                a/=2;
            }else {
                b/=2;
            }
        }
        return a;
    }
}
